/*
 *
 *      Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the pig4cloud.com developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: lengleng (wangiegie@gmail.com)
 *
 */

package com.pig4cloud.pigx.admin.controller;

import cn.hutool.core.lang.Assert;
import com.pig4cloud.pigx.admin.api.dto.RegimenStationDto;
import com.pig4cloud.pigx.admin.api.entity.OverallRegimenStation;
import com.pig4cloud.pigx.admin.api.entity.OverallSupervise;
import com.pig4cloud.pigx.admin.service.OverallRegimenStationService;
import com.pig4cloud.pigx.common.core.util.R;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@AllArgsConstructor
@RequestMapping("/regimenStation")
@Tag(description = "regimenStation", name = "四全水情站点信息")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class OverallRegimenStationController {

    private final OverallRegimenStationService regimenStationService;

    /**
     *
     * @return R
     * @author lfx
     * @date 2024/8/10 10:34
     * @Desc 查询水情站点信息列表
     **/
    @GetMapping(value = "/selectList")
    public R selectList(RegimenStationDto res) {
        return R.ok(regimenStationService.selectList(res));
    }

    /**
     *
     * @param
     * @return R
     * @author lfx
     * @date 2024/8/10 10:39
     * @Desc 数据添加接口
     **/
    @RequestMapping(value = "/save", produces = "application/json", method = RequestMethod.POST)
    public R save(@RequestBody @Valid OverallRegimenStation regimenStation) {
        return R.ok(regimenStationService.save(regimenStation));
    }

    /**
     *
     * @param
     * @return R
     * @author lfx
     * @date 2024/8/10 10:39
     * @Desc 数据修改接口
     **/
    @RequestMapping(value = "/update", produces = "application/json", method = RequestMethod.POST)
    public R update(@RequestBody @Valid OverallRegimenStation regimenStation) {
        Assert.notNull(regimenStation.getId(), "id不能为空");
        return R.ok(regimenStationService.updateById(regimenStation));
    }

    /**
     *
     * @param
     * @return R
     * @author lfx
     * @date 2024/8/10 10:39
     * @Desc 数据删除接口
     **/
    @RequestMapping(value = "/remove/{id}", produces = "application/json", method = RequestMethod.DELETE)
    public R remove(@PathVariable String id) {
        return R.ok(regimenStationService.removeById(id));
    }
}
